﻿/*=================================================================
* 版权信息：Copyright (C) 2005-2011 捷点科技 All Rights Reserved.
* 文件名称：CNVP_OrderProShopMustInfo.cs
* 创建标识：曾乃强 15158756652 2011-04-19 09:04:41
* 修改标识：
* 功能描述：
===================================================================*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using CNVP.Framework.Helper;
using CNVP.Config;

namespace CNVP.JShop.DAL
{
    /// <summary>
    /// 对*CNVP_OrderProShopMustInfo*操作数据库(针对SQL Server)的实现
    /// </summary>
    public class CNVP_OrderProShopMustInfo
    {
       private string Prefix = DBConfig.Prefix;
        #region DAL
        /// <summary>
        /// 添加
        /// </summary>
        public int Insert(Model.CNVP_OrderProShopMustInfo obj)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("insert into  " + Prefix + "OrderProShopMustInfo ([OrderID],[ProductID],[ProDetailsID],[StandardValue],[ProTypeRefShopMustInfoID])");
            sql.Append("values(@OrderID,@ProductID,@ProDetailsID,@StandardValue,@ProTypeRefShopMustInfoID)");
            
            SqlParameter[] pra = {
                            new SqlParameter("@OrderID",obj.OrderID),
                            new SqlParameter("@ProductID",obj.ProductID),
							new SqlParameter("@ProDetailsID",obj.ProDetailsID),
							new SqlParameter("@StandardValue",obj.StandardValue),
							new SqlParameter("@ProTypeRefShopMustInfoID",obj.ProTypeRefShopMustInfoID)
                                 };
            return DbHelper.ExecuteNonQuery(sql.ToString(), pra);
        }

        /// <summary>
        /// 删除
        /// </summary>
        public int Delete(Model.CNVP_OrderProShopMustInfo obj)
        {
           StringBuilder sql = new StringBuilder();
           sql.Append("delete from " + Prefix + "OrderProShopMustInfo where [ID] = @ID");
           SqlParameter[] pra = {
                                new SqlParameter("@ID",obj.ID)
						
                                };
           return DbHelper.ExecuteNonQuery(sql.ToString(),pra);
        }
        #endregion

        /// <summary>
        /// 查看全部,   By OrderID
        /// </summary>
        public List<Model.CNVP_OrderProShopMustInfo> LoadAll(int OrderID)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("select [ID],[ProDetailsID],[StandardValue],[ProTypeRefShopMustInfoID] from " + Prefix + "OrderProShopMustInfo");
            sql.Append(" where [OrderID] = @OrderID");
            SqlParameter[] pra = {
                                 new SqlParameter("@OrderID",OrderID)
						
                                    };
            DataTable DT = DbHelper.ExecuteTable(sql.ToString(),pra);
            List<Model.CNVP_OrderProShopMustInfo> list = new List<Model.CNVP_OrderProShopMustInfo>();
            if (DT != null && DT.Rows.Count > 0)
            {
                foreach (DataRow dr in DT.Rows)
                {
                    Model.CNVP_OrderProShopMustInfo cnvp_orderproshopmustinfo = new Model.CNVP_OrderProShopMustInfo();
                    cnvp_orderproshopmustinfo.ID = dr["ID"] is DBNull ? 0 : (int)dr["ID"];
                    cnvp_orderproshopmustinfo.ProDetailsID = dr["ProDetailsID"] is DBNull ? 0 : (int)dr["ProDetailsID"];
                    cnvp_orderproshopmustinfo.StandardValue = dr["StandardValue"] is DBNull ? String.Empty : (string)dr["StandardValue"];
                    cnvp_orderproshopmustinfo.ProTypeRefShopMustInfoID = dr["ProTypeRefShopMustInfoID"] is DBNull ? 0 : (int)dr["ProTypeRefShopMustInfoID"];
                    list.Add(cnvp_orderproshopmustinfo);
                }
            }
            return list;

        }
    }
}

